<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="renderer" content="webkit">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
<title>网站后台管理</title>
<link rel="stylesheet" type="text/css" href="__STATIC__/admin/layui/css/layui.css"/>
<link rel="stylesheet" type="text/css" href="__STATIC__/admin/css/admin.css"/>
<script type="text/javascript" charset="utf-8" src="__STATIC__/ueditor/ueditor.config.js"></script>
<script type="text/javascript" charset="utf-8" src="__STATIC__/ueditor/ueditor.all.min.js"> </script>
<script type="text/javascript" charset="utf-8" src="__STATIC__/ueditor/lang/zh-cn/zh-cn.js"></script>
<style>
.pic_box{ padding-top:10px;}
</style>
</head>
<body>
<form class="layui-form column-content-detail edit-form" method="post">
{if condition="isset($info)"}
<input type="hidden" name="id" value="{$info.id}" />
<input type="hidden" name="mid" value="{$info.mid}">
<input type="hidden" name="tid" value="{$info.tid}">
{else/}
<input type="hidden" name="mid" value="{$_tinfo.mid|default=0}">
<input type="hidden" name="tid" value="{$_tinfo.id|default=0}">
{/if}
  <div class="layui-tab">
    <ul class="layui-tab-title">
      {foreach $_group as $gk=>$gv} 
      <li {if condition="$gk eq 0"}class="layui-this"{/if}>{$gv}</li>
      {/foreach}
    </ul>
    <div class="layui-tab-content">
      
      {foreach $_group as $gk=>$gv} 
      <div class="layui-tab-item {if condition="$gk eq 0"}layui-show{/if}">
        
        {volist name='_fields' id='field'}
        {if condition="$field['group'] eq $gk"}
        {switch name="field.type"}
        {case value='number'}
        <div class="layui-form-item">
          <label class="layui-form-label">{$field.title}：</label>
          <div class="layui-input-block">
            <input type="number" name="{$field.name}" value="{$info[$field['name']]|default=$field['value']}" required lay-verify="required" placeholder="请输入{$field.title}" autocomplete="off" class="layui-input">
          </div>
        </div>
        {/case}
        
        {case value='text'}
        <div class="layui-form-item">
          <label class="layui-form-label">{$field.title}：</label>
          <div class="layui-input-block">
            <input type="text" name="{$field.name}" value="{$info[$field['name']]|default=$field['value']}" required lay-verify="required" placeholder="请输入{$field.title}" autocomplete="off" class="layui-input">
          </div>
        </div>
        {/case}
        
        {case value='textarea'}
        <div class="layui-form-item layui-form-text">
          <label class="layui-form-label">{$field.title}：</label>
          <div class="layui-input-block">
            <textarea name="{$field.name}" placeholder="请输入{$field.title}" class="layui-textarea">{$info[$field['name']]|default=''}</textarea>
          </div>
        </div>
        {/case}
        
        {case value='radio'}
        <div class="layui-form-item">
          <label class="layui-form-label">{$field.title}：</label>
          <div class="layui-input-block">
            {php}$option = config_parse(3,$field['option']);{/php}
            {foreach $option as $ok=>$ov} 
            <input type="radio" name="{$field.name}" value="{$ok}" title="{$ov}" {if condition="isset($info[$field['name']]) && $info[$field['name']] eq $ok"}checked{elseif condition="$field['value'] eq $ok"/}checked{/if}>
            {/foreach}
          </div>
        </div>
        {/case}
        
        {case value='checkbox'}
        <div class="layui-form-item">
          <label class="layui-form-label">{$field.title}：</label>
          <div class="layui-input-block">
            {php}
            $option = config_parse(3,$field['option']); 
            if(isset($info[$field['name']]) && !empty($info[$field['name']])){ 
            	$oval = explode(',',$info[$field['name']]);
            }
            {/php}
            {foreach $option as $ok=>$ov} 
            <input type="checkbox" name="{$field.name}[]" title="{$ov}" {if condition="isset($oval) && in_array($ok,$oval)"}checked{elseif condition="$field['value'] eq $ok"/}checked{/if}>
            {/foreach}
          </div>
        </div>
		{/case}
        
        {case value='select'}
        <div class="layui-form-item">
          <label class="layui-form-label">{$field.title}：</label>
          <div class="layui-input-block">
            <select name="{$field.name}">
              <option value="">请选择{$field.title}</option>
              {php}$option = config_parse(3,$field['option']);{/php}
              {foreach $option as $ok=>$ov} 
              <option value="{$ok}" {if condition="isset($info[$field['name']]) && $info[$field['name']] eq $ok"}selected{elseif condition="$field['value'] eq $ok"/}selected{/if}>{$ov}</option>
              {/foreach}
            </select>
          </div>
        </div>
        {/case}
        
        {case value='datatime'}
        <div class="layui-form-item">
          <label class="layui-form-label">{$field.title}：</label>
          <div class="layui-input-block">
            <input type="text" name="{$field.name}" value="{$info[$field['name']]|default=''}" placeholder="请选择{$field.title}" autocomplete="off" class="layui-input date_input">
          </div>
        </div>
        {/case}
        
        {case value='pic'}
        <div class="layui-form-item">
          <label class="layui-form-label">{$field.title}：</label>
          <div class="layui-input-block">
            <input type="file" name="mfile" lay-ext="jpg|png|gif" class="layui-upload-file">
            {if condition="isset($info[$field['name']]) && !empty($info[$field['name']])"}
            <div class="pic_box"><img src="{$info.pic}" height="100"></div>
            <input type="hidden" name="{$field.name}" class="pic_input" value="{$info[$field['name']]}">
            {else/}
            <div class="pic_box"></div>
            <input type="hidden" name="{$field.name}" class="pic_input" value="">
            {/if}
          </div>
          
        </div>
        {/case}
        
        {case value='ueditor'}
        <div class="layui-form-item layui-form-text">
          <label class="layui-form-label">{$field.title}：</label>
          <div class="layui-input-block">
            <script id="editor_{$field.name}" name="{$field.name}" type="text/plain" style="height:500px;">
            {$info[$field['name']]|default=''}
        	</script>
            <script type="text/javascript">
				var editor = UE.getEditor('editor_{$field.name}');
			</script>
          </div>
        </div>
        {/case}

        {/switch}
        {/if}
        {/volist}
      </div>
      {/foreach}
      
    </div>
  </div>
  <div class="layui-form-item" style="padding-left: 10px;">
    <div class="layui-input-block">
      <button class="layui-btn layui-btn-normal" lay-submit lay-filter="arc_form">立即提交</button>
      <button type="reset" class="layui-btn layui-btn-primary">重置</button>
    </div>
  </div>
</form>
<script>
var module_path = '__STATIC__/admin/js/module/'	;
</script>
<script src="__STATIC__/js/jquery.min.js" type="text/javascript" charset="utf-8"></script> 
<script src="__STATIC__/admin/layui/layui.js" type="text/javascript" charset="utf-8"></script> 
<script src="__STATIC__/admin/js/common.js" type="text/javascript" charset="utf-8"></script> 
<script src="__STATIC__/js/common.js" type="text/javascript" charset="utf-8"></script> 
<script>
		
layui.use(['form', 'jquery', 'laydate', 'layer', 'upload'], function() {
	var form = layui.form(),
		layer = layui.layer,
		$ = layui.jquery,
		laydate = layui.laydate;

	//获取当前iframe的name值
	var iframeObj = $(window.frameElement).attr('name');
	
	//监听提交
	form.on('submit(arc_form)', function(data) {
		//layer.msg(JSON.stringify(data.field));
		ajax_post('edit-form',false,'','');
		return false;
	});
	
	$('.date_input').on('click',function(){
		var elem = $(this)[0];
		laydate({
			elem: elem 
		});		
	});

	form.render();

	layui.upload({
		url: "{:url('File/upload')}"
		,success: function(res, input){
			if(res.code == 1){
				layer.msg(res.msg);	
				$(input).parents('.layui-input-block').find('.pic_input').val(res.data.src);
				$(input).parents('.layui-input-block').find('.pic_box').html('<img src="'+res.data.src+'" height="100">');
			}else{
				layer.msg(res.msg);		
			}
		}
	});
});

</script>
</body>
</html>